![]() |
Kinetis SDK API Reference Manual
1.0.0-beta
Freescale Semiconductor, Inc.
|
The Kinetis SDK provides the bare metal abstraction layer for synchronization, mutual exclusion, message queue, etc. More...
Data Structures | |
| struct | sync_object_t |
| Type for an synchronization object. More... | |
| struct | lock_object_t |
| Type for a resource locking object. More... | |
| struct | event_object_t |
| Type for an event group object. More... | |
| struct | msg_queue_t |
| Type for a message queue declaration and creation. More... | |
| struct | POLL_SLOT_STRUCT |
| Poll function slot. More... | |
| struct | POLL_STRUCT |
| Poll structure. More... | |
Macros | |
| #define | kSyncWaitForever kSwTimerMaxTimeout |
| Constant to pass as timeout value in order to wait indefinitely. More... | |
| #define | FSL_RTOS_CURRENT_TASK ((task_handler_t)0) |
| Macro passed to the task_destroy function to destroy the current task. | |
Typedefs | |
| typedef uint32_t | event_group_t |
| Type for an event flags group, bit 32 is reserved. | |
| typedef void(* | task_t )(void *param) |
| Type for a task pointer. | |
| typedef task_t | task_handler_t |
| Type for a task handler, returned by the task_create function. | |
| typedef uint32_t | task_stack_t |
| Type for a task stack. | |
| typedef msg_queue_t * | msg_queue_handler_t |
| Type for a message queue declaration and creation. | |
| typedef void * | msg_queue_item_t |
| Type for a message queue item. | |
Synchronization | |
| #define | sync_object_declare(obj) sync_object_t obj |
| Create the synchronization object. More... | |
Resource locking | |
| #define | lock_object_declare(obj) lock_object_t obj |
| Create the locking object. More... | |
Thread management | |
| #define | FSL_RTOS_TASK_DEFINE(task, stackSize, name, usesFloat) uint8_t fslTaskName_##task[] = name |
| Define a task. More... | |
| #define | task_create(task, priority, param, handler) |
| Creates and sets the task to active. More... | |
Message queues | |
| #define | MSG_QUEUE_DECLARE(name, number, size) |
| This macro statically reserves the memory required for the queue. More... | |
Critical Sections | |
| #define | rtos_enter_critical interrupt_disable_global |
| Ensures the following code will not be preempted. | |
| #define | rtos_exit_critical interrupt_enable_global |
| Allows preemption. | |
Task poll | |
| void | Poll (void) |
| Poll every function registered in the POLL_STRUCT. More... | |
| void | POLL_init (void) |
| Initialize the POLL_STRUCT. More... | |
| #define | POLL_MAX_NUM 5 |
| Maximum number of functions called every time Poll function is invoked. | |
| struct sync_object_t |
| struct lock_object_t |
| struct event_object_t |
Data Fields | |
| volatile bool | isWaiting |
| Is any task waiting for a timeout on this event. | |
| uint8_t | timerId |
| The software timer channel this event bind to. | |
| volatile event_group_t | flags |
| The flags status. | |
| event_clear_type | clearType |
| Auto clear or manual clear. | |
| struct msg_queue_t |
Data Fields | |
| void ** | queueMem |
| Points to the queue memory. | |
| uint16_t | number |
| Stores the elements in the queue. | |
| uint16_t | size |
| Stores the size in words of each element. | |
| uint16_t | head |
| Index of the next element to be read. | |
| uint16_t | tail |
| Index of the next place to write to. | |
| sync_object_t | queueSync |
| Sync object wakeup tasks waiting for msg. | |
| volatile bool | isEmpty |
| Whether queue is empty. | |
| struct POLL_STRUCT |
Data Fields | |
| POLL_SLOT_STRUCT | p_slot [POLL_MAX_NUM] |
| polling function pointer array | |
| uint32_t | registered_no |
| number of registered function | |
| #define kSyncWaitForever kSwTimerMaxTimeout |
| #define sync_object_declare | ( | obj | ) | sync_object_t obj |
To be used instead of a standard declaration.
| obj | The sync object to create. |
| #define lock_object_declare | ( | obj | ) | lock_object_t obj |
To be used instead of a standard declaration.
| obj | The lock object to create. |
| #define FSL_RTOS_TASK_DEFINE | ( | task, | |
| stackSize, | |||
| name, | |||
| usesFloat | |||
| ) | uint8_t fslTaskName_##task[] = name |
This macro is used to define resources for a task statically, then task_create will create task based-on these resources.
| task | The task function. |
| stackSize | Number of elements in the stack for this task. |
| name | String to assign to the task. |
| usesFloat | Boolean that indicates whether the task uses the floating point unit. |
| #define task_create | ( | task, | |
| priority, | |||
| param, | |||
| handler | |||
| ) |
This macro is used with FSL_RTOS_TASK_DEFINE to create a task. Here is an example demonstrating how to use:
| task | The task function. |
| priority | Initial priority of the task. |
| param | Parameter to be passed to the task when it is created. |
| handler | Returns the identifier to be used afterwards to destroy the task. |
| kSuccess | The task was successfully created. |
| kError | The task creation failed. |
| #define MSG_QUEUE_DECLARE | ( | name, | |
| number, | |||
| size | |||
| ) |
| name | Identifier for the memory region. |
| number | Number of elements in the queue. |
| size | Size of every element in words. |
| void Poll | ( | void | ) |
Every task function registered in the POLL_STRUCT will be called in turn. This function should be used in a infinite loop in main.
Here is an example demonstrating how to use:
| void POLL_init | ( | void | ) |
The struct POLL_STRUCT must be initialized before task functions are registered.